﻿using System;
using System.IO;
using System.Windows.Data;
using System.Windows.Media.Imaging;

namespace Rio.Framework.Pages.Helpers
{
    public class ByteArrayToBitmapImageConverter : IValueConverter
    {

        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            BitmapImage L_biImg = new BitmapImage();
            using (MemoryStream ms = new MemoryStream((Byte[])value, 0, ((Byte[])value).Length))
            {
                L_biImg.SetSource(ms);
            }
            return L_biImg;
        }

        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
